package chen.huai.jie.spring.xmlconfig.job;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class ApplicationJob {
    private Logger logger = LoggerFactory.getLogger(ApplicationJob.class);

    @Autowired(required = false)
    private StringRedisTemplate stringRedisTemplate;

    public void doSomething() {
        stringRedisTemplate.opsForValue().set("name", "chenhuaijie", 10, TimeUnit.SECONDS);
        logger.info(String.format("Get name from redis:%s.", stringRedisTemplate.opsForValue().get("name")));
        logger.info(String.format("执行定时任务:doSomething."));
    }

    public void doSomethingWithCrom() {
        logger.info(String.format("执行定时任务:doSomethingWithCrom."));
    }
}
